<!doctype html>
<html lang=en>
<head>
<meta  http-equiv="Content-Type" content="text/html; charset=utf-8" />
</head>

<body>
<?php
require_once '../BusinessLogicTier/DanhMucSPBUS.php';
require_once '../BusinessLogicTier/SanPhamBUS.php';
require_once '../BusinessLogicTier/TinRaoVatBUS.php';
require_once '../BusinessLogicTier/TinRaoVatBUS.php';
require_once '../BusinessLogicTier/ThongTinNguoiDungBUS.php';
require_once '../BusinessLogicTier/TinhBUS.php';
require_once '../BusinessLogicTier/NguoiDungBUS.php';
require_once '../BusinessLogicTier/LoaiTinRaoVatBUS.php';
require_once '../BusinessLogicTier/BinhLuanBUS.php';
 
//Test DanhMucSPBUS
$dmspBUS = new DanhMucSPBUS();
$dmsp = $dmspBUS->getDanhMucSP();
foreach ($dmsp as $obj){
 print $obj->getMaDMSP() . ": " . $obj->getTenDMSP() . "<br>\n";
} 
 
//Test SanPhamBUS
$spBUS = new SanPhamBUS();
$sp = $spBUS->getSanPham();
foreach ($sp as $obj){
 print $obj->getMaSP() . " " . $obj->getTenSP() . " " . $obj->getMaDMSP() . "<br>\n";
}
$sp1 = $spBUS->getSanPhamByMaSP('1');
print $sp1->getMaSP() . " " . $sp1->getTenSP() . " " . $sp1->getMaDMSP() . "<br>\n";


//Test TinRaoVatBUS
$trvBUS = new TinRaoVatBUS();
$trv = $trvBUS->getTinRaoVatByMaTRV('1');
print '<br>Test tin rao vat<br>';
print $trv->getTieuDe();

print '<br>Test get tin rao vat by madmsp<br>';
$trv = $trvBUS->getTinRaoVatByMaDMSP('1');
foreach ($trv as $obj){
	print $obj->getTieuDe() . "<br>";
}

//Test ThongTinNguoiDungBUS
$ttndBUS = new ThongTinNguoiDungBUS();
$ttnd = $ttndBUS->getThongTinNguoiDungByMaND('1');
print "<br>Test thong tin nguoi dung<br>";
print $ttnd->getDiaChi();

//Test TinhBUS
$tinhBUS = new TinhBUS();
$tinh = $tinhBUS->getTinhByMaTRV('1');
print "<br>Test get tinh by ma trv<br>";
foreach ($tinh as $obj){
	print $obj->getTenTinh() . "<br>";
}

//Test NguoiDungBUS
$nguoiDungBUS = new NguoiDungBUS();
$nguoiDung = $nguoiDungBUS->getNguoiDungByMaND('1');
print "<br>Test get nguoi dung by ma nguoi dung<br>";
print $nguoiDung->getEmail() . "<br>";
			
//Test LoaiTinRaoVatBUS
$loaiTRVBUS = new LoaiTinRaoVatBUS();
$listLoaiTRV = $loaiTRVBUS->getLoaiTinRaoVat();

print "<br>Get tat ca loai tin rao vat<br>";
foreach ($listLoaiTRV as $obj){
	print $obj->getTenLoaiTRV() . "<br>";
}	

$loaiTRV = $loaiTRVBUS->getLoaiTRVByMaLoaiTRV('1');
print "<br>Get loai tin rao vat theo ma loai tin rao vat<br>";
print $loaiTRV->getTenLoaiTRV() . "<br>";

//Test BinhLuanBUS
$binhLuanBUS = new BinhLuanBUS();
$binhLuan = $binhLuanBUS->getBinhLuanByMaTRV('1');
foreach ($binhLuan as $obj){
	print $obj->getMaND() . "<br>";
}


//Demo insert binhluan
// $thoigian = date('Y-m-d H:i:s');
// $bl = new BinhLuan("", 1, 1, $thoigian, 'quá đắt');
// $binhLuanBUS->insert($bl);

//Demo insert sanpham
// $sanpham = new SanPham("", "Xe Camry", 3);
// $spBUS->insert($sanpham);

//Demo insert into tinraovat
// $thoigian = date('Y-m-d H:i:s');
// $trvObj = new TinRaoVat("", 1, 'qqqq', 1000000, 'wwwwwwww', 'hhhhhhhhhh', $thoigian, 0, 1, 1);
// $trvBUS->insert($trvObj);

?>
 
</body>
</html>
 

 